package com.custom.starter.config;

import com.custom.starter.service.CustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动装配类
 *
 * @author chenfoxin
 * @date 2022年06月16日 7:23
 */
@Configuration
@EnableConfigurationProperties(CustomProperties.class)
@ConditionalOnProperty(prefix = "spring.custom.starter",name = {"enabled"},havingValue = "true")
public class CustomAutoConfig {

    @Autowired
    private CustomProperties properties;

    @Bean
    public CustomService demoService() {
        return new CustomService(properties);
    }
}
